package com.why.constantpool;

import com.why.basictype.U2;

import java.io.InputStream;

/**
 * @author by xiaoTian
 * @date 2022/5/21.
 */
public class ConstantNameAndTypeInfo extends ConstantPoolInfo{

    private short nameIndex;
    private short descriptorIndex;

    public ConstantNameAndTypeInfo(byte tag){
        setTag(tag);
    }


    @Override
    public void read(InputStream inputStream) {
        U2 nameIndexU = U2.read(inputStream);
        U2 descriptorIndexU = U2.read(inputStream);
        this.nameIndex = nameIndexU.getValue();
        this.descriptorIndex = descriptorIndexU.getValue();
    }

    @Override
    public String toString() {
        return "ConstantNameAndTypeInfo{" +
                "nameIndex=" + nameIndex +
                ", descriptorIndex=" + descriptorIndex +
                '}';
    }
}
